package com.sgl.retrofitdemo.net.model;

import com.sgl.retrofitdemo.net.DataSourceFactory;
import com.sgl.retrofitdemo.net.RepositoryUtil;
import com.sgl.retrofitdemo.net.api.UserApi;
import com.sgl.retrofitdemo.net.entity.request.UserInfo;
import com.sgl.retrofitdemo.net.entity.respons.UserInfoEntity;

import rx.Observable;

/**
 * Created by sunqiyong on 2016/11/13.
 */

public class UserDataModel implements IUserModel {


    private UserApi mUserApi;

    public UserDataModel(UserApi mUserApi) {
        this.mUserApi = mUserApi;
    }

    public static UserDataModel getInstance(){
        return DataSourceFactory.getInstance().createUserDataModel();
    }

    @Override
    public Observable<UserInfoEntity> testPost(UserInfo userInfo) {
        return RepositoryUtil.extractData(mUserApi.testPost(userInfo));
    }

    @Override
    public Observable<UserInfoEntity> testGet(String count, String password) {
        return RepositoryUtil.extractData(mUserApi.testGet(count,password));
    }
}
